1. Field of the Invention
The present invention relates to a data management system having a data link structure which is used in an information processing apparatus in which a nonvolatile memory is used as a data recording medium, and an extended recording apparatus therefor, such as a handheld computer, an electronic notebook, a cellular phone, a memory card reader, etc. The present invention also relates to a data management method which uses the data management system.
2. Description of the Related Art
Conventionally, hard magnetic disk drives have been used in many computers as data recording devices. The features and advantages of the hard magnetic disk drives reside in that data is recorded in a nonvolatile manner, and that reading and rewriting of data can be performed by units of one sector (for example, 512 bytes), and overwriting of data is possible. On the other hand, disadvantages of these type of hard disk drives reside in that their physical sizes are large, they consume a relatively large amount of electric power, and they are sensitive to vibration and shock.
The advantages of semiconductor memories formed of flash memories reside in that they have a compact size and are resistant to vibration and shock, and that power consumption thereof is much smaller as compared with the above hard magnetic disk drives. On the other hand, the disadvantages of such semiconductor memories formed of flash memories reside in that reading and writing of data are performed by units of one byte (word), that it is necessary to perform a data erasing operation (typically, 64 kilobytes) for rewriting data, and overwriting of data is impossible, and that the number of times that a block erasing operation can be performed is limited (typically, up to one hundred thousand times).
In a flash memory, electrical writing and erasing of data are possible, and the written data are stored in a nonvolatile manner unless it is erased (typically, 64 kilobytes). The erasing operation in the flash memory is performed by units of a block (typically, 64 kilobytes), which is significantly greater than the minimum unit of rewriting in the hard magnetic disk drive (for example, 512 bytes).
The erasing operation in the flash memory is typically achieved by extracting an electron from a floating gate such that the threshold value of a memory cell is decreased (about 3 V or less). The writing operation in the flash memory is typically achieved by injecting an electron into a floating gate such that the threshold value of a memory cell is increased (about 5.5 V or more).
Generally, in a flash memory, the time required for writing a 1 byte (word) is about 20 microseconds. However, the time required for an erasing operation (typically, 64 kilobytes) is about 1 second, which is much longer than the above writing operation time. Furthermore, disadvantageously, the guaranteed number of times of the erasing operation is limited (typically, up to one hundred thousand times). Thus, when the erasing operation (typically, 64 kilobytes) is performed for rewriting one sector of data (for example, 512 bytes), one or more seconds are required as a data rewriting time (a data erasing time plus a data writing time), which is much longer than the data rewriting time in the hard magnetic disk drive.
For example, Japanese Laid-Open Publication No. 6-202821 and Japanese Laid-Open Publication No. 9-97139 propose methods for performing data management in an efficient manner with the minimum number of times of the erasing operation that consumes a long operation time, i.e., techniques for achieving an efficient file system which is adapted to flash memories.
In Japanese Laid-open Publication No. 6-202821, in order to realize a file storage system similar to that of a solid memory disk using a plurality of flash memories, an erasure block of each flash memory includes a data space for storing sectors of data and a block/sector conversion table. In the block/sector conversion table, sectors of each data which are stored in the data space of the block are identified by sector numbers.
In order to realize a file system for flash memories, a management apparatus disclosed in Japanese Laid-Open Publication No. 9-97139 includes a management section and an abandonment section. The management section forms a plurality of storage blocks each including a data region and a management region corresponding to the data region in the flash memory. In each block, state information which represents the recording state of the data region is stored in the management region. The management section controls accesses to the data region based on the state information. The abandonment section updates the state information stored in a management region in a designated storage block into information representing that the designated data region is invalid, thereby abandoning this designated data region.
Japanese Laid-Open Publication No. 1-251230 and Japanese Laid-Open Publication No. 7-44451 propose techniques related to a data link structure. Herein, the data link structure means a structure where data itself possesses information about the relationship among the sites of data distributed over a recording medium, e.g., a data sequence order, and where data are interrelated to each other in the form of a logical chain. Hereinafter, information about the relationship among the sites where data are stored is referred to as data link information.
Japanese Laid-Open Publication No. 1-251230 describes a program conversion system. This system includes a storage section and a control section. The storage section stores data in a plurality of blocks while storing previous-link information which points to a previous block and subsequent-link information which points to a subsequent block in each block. The control section controls the data linkage such that previous-link information of the first block points to the last block, and subsequent-link information of the last block points to the first block.
Japanese Laid-Open Publication No. 7-44451 describes a data storage apparatus which includes a data storage section and first and second reading sections. The data storage section stores, in each of a plurality of data storage regions, storage address data for previous and subsequent data together with main data. The first reading section reads stored data according to an order determined based on the storage address data. The second reading section reads the stored data according to a predetermined order in the case of a problem with the next data storage address such that the next data cannot be read out.
Hereinafter, a conventional data management method is described in detail with reference to FIGS. 13 through 16.
In a memory where the minimum physical unit of data which is erased at one time (herein, referred to as “erasure block”; shown in FIG. 13 as an area enclosed by solid lines) is relatively large (e.g., 64 kilobytes), when data management is to be performed such that data is erased in units of a sufficiently small virtual data segment, in usual cases, an erasure block (64 kilobytes) is virtually divided into a plurality of sectors (e.g., 1 sector=512 bytes; shown in FIG. 13 as areas enclosed by broken lines).
FIG. 14 shows a structure of a sector. As shown in FIG. 14, each of these sectors stores, in addition to main data, an address number which is used for identifying data to be written, and a flag which indicates a write state (which includes three types of state, “DATA VALID”, “DATA INVALID”, and “UNUSED”).
Writing of data is performed in units of a sector by updating the flag which indicates the write state from “UNUSED” to “DATA VALID”. When rewriting (updating) data or erasing data, a physical erasing operation is not performed on data to be updated or erased. Instead, the flag of a sector to be updated or erased is updated from “DATA VALID” to “DATA INVALID”, whereby validity/invalidity of the entire data in that sector can be expressed as shown in FIG. 15.
After such rewriting of data is repeated, there may be a plurality of logical sectors (sectors that are managed with the above-described address numbers and/or state information) having the same address number. However, in this case, the number of logical sectors which have a flag which indicates “DATA VALID” is always one. When reading data, the latest data is specified by sequentially searching through logical sectors, using the address number and the valid flag as conditions for the search.
When data is rewritten, what is actually performed is writing of data in an unused sector. Although old data is virtually erased (the flag is invalidated), the old data is physically left at the same site in a memory region. After the entire erasure block has been occupied with data, when a further data writing/updating operation is performed, it is necessary to perform an erasing operation on the erasure block in order to render sectors that contain invalid data available. This erasing operation is referred to as a “reconstruction (or reclaim)” operation.
In order to perform this reconstruction operation, it is necessary to reserve one erasure block. In this operation, from any selected block (the upper block in FIG. 16), only data stored in sectors which have valid flags are copied, in units of one sector, into the reserved erasure block (the lower block), and then, the data in the selected block are all erased. Through this process, relocation of data is performed such that unused sectors are gathered in a group as shown in the lower part of FIG. 16. One reserved erasure block is sufficient regardless of the number of erasure blocks which are used for data management, but the reserved erasure block must have the same physical capacity as those of the other erasure blocks.
FIG. 17 illustrates an exemplary state of conventional data storage. As shown in FIG. 17, for each data, an identification (ID) number which is unique to the data in the system, state information which indicates “DATA VALID” or “DATA INVALID”, header information concerning stored data, such as data size, and main data are stored in physically-contiguous address regions.
FIG. 18 illustrates another exemplary state of conventional data storage. As shown in FIG. 18, for each data, an identification (ID) number which is unique to the data in the system, state information which indicates “DATA VALID” or “DATA INVALID”, data size, and header information concerning data stored in a leading address among the addresses where main data is stored (link information) are stored in physically-contiguous address regions. The main data does not physically follow the address region where the header information is stored. That is, the main data is stored in an address region physically following the leading address designated in the header information. In this storage method, the header information and the main data are stored in a separated manner, and header regions of respective data are managed together. Thus, an area to be searched through for a desired piece of data (ID number) is small, and accordingly, when reading data, data processing can be performed at a high rate.
Hereinafter, a conventional data management method is described in detail with reference to FIGS. 19 through 29.
FIG. 19 is a block diagram showing a structure of a file system using a conventional flash memory, which was conceived by one of the present inventors and is disclosed in Japanese Laid-Open Publication No. 2001-051889 (Japanese Patent Application No. 11-254973). In FIG. 19, a flash memory file system 1 includes a file system control section 2, a file system memory section 3, a flash memory control section 4, a flash memory section 5, and an application or operating system (OS) 6.
The file system control section 2 controls the processing to take place in the file system 1. The file system memory section 3 stores data management information which is used by the flash memory file system 1. The flash memory control section 4 controls data processing for the flash memory section 5 (e.g., data write processing, data read processing, etc.). The flash memory section 5 is a means for storing data. The application or operating system (OS) 6 is a program which requests the flash memory file system 1 to perform data processing.
FIG. 20 is a data structure diagram showing the data structure stored in the flash memory section 5. As shown in FIG. 20, the flash memory section 5 includes a plurality of physical blocks or “erasure blocks” 51. Each erasure block 51 is divided into a plurality of physical sectors 52 (which are the units by which data is processed). Each physical sector 52 within each erasure block 51 has a unique physical sector number. If each erasure block 51 is 64 Kbytes in size and each physical sector 52 is 512 bytes in size, then each erasure block 51 includes 128 physical sectors 52. That is, for example, physical block #0 includes a block control sector 52a containing control information, and physical sectors #1 to #127 as data regions.
One of the erasure blocks 51 in the flash memory section 5 is secured or reserved in advance as a reserve erasure block (in which data has yet to be written) for use in the reconstruction of the file system 1. The first physical sector 52 of each erasure block 51 is secured in advance as a block control sector 52a (physical sector #0) for storing the control information for that erasure block 51.
In the block control sector 52a of each erasure block 51, 2 bytes of state information concerning the erasure block 51, 2 bytes of state information concerning the physical sector (#1) 52, 2 bytes of state information concerning the physical sector (#2) 52, . . . 2 bytes of state information concerning the physical sector (#127) 52 are sequentially provided. Thus, the block control sector 52a contains 2 bytes.times.128=256 bytes of information.
The state information concerning the erasure block 51 (having the size of 64 kilobytes) includes a logical block number (one of 0 to 255) as assigned by the file system control section 2 and data which represents one of the five following block states: (1) “111111111b” representing “UNUSED”: (2) “11111110b” representing “RECEIVING DATA”; (3) “11111100b” representing “ERASING ORIGINAL BLOCK”; (4) “11111000b” representing “INCLUDES DATA”; or (5) “11110000b” representing “BLOCK FULL”. The label “b” at the end of each bit string indicates “binary”.
Similarly to the state information of the erasure block 51, the state information of each sector 52 of the erasure block 51 includes: a logical sector number (0 to 4095; 12 bits) which is uniquely assigned within the system by the file system control section 2; and data which represents one of the following five sector states (4 bits): (1) “1111b” representing “UNUSED”; (II) “1110b” representing “WRITING DATA”: (III) “1100b” representing “DATA WRITE COMPLETE”; (IV) “1100b” representing “DATA VALID”: or (V) “0000b” representing “DATA IVALID”. The label “b” at the end of each bit string indicates “binary”.
FIG. 21 is a data structure diagram showing a structure of management data concerning each erasure block 51 (hereinafter referred to as the “block information table 10”) stored in the file system memory section 3 of the file system shown in FIG. 19, which shows the data structure of the respective erasure blocks 51.
In the block information table 10 of FIG. 21, each information unit consists of a physical block number, a logical block number, and a block state. Thus, the block information table 10 illustrates an erasure block 51 whose physical block number=0, logical block number=0 and block state=“INCLUDES DATA”: an erasure block 51 whose physical block number=1, logical block number=1, and block state=“BLOCK FULL” (or “DATA FULL”); and so on.
FIG. 22 is a data structure diagram showing a structure of management data concerning each physical sector 52 (hereinafter referred to as the “sector information table 11”) stored in the file system memory section 3 of the file system shown in FIG. 19, which shows the data structure of the respective physical sectors 52.
In the sector information table 11 of FIG. 22, each information unit consists of a physical block number, a physical sector number, a logical sector number, and a sector state. Thus, the sector information table 11 illustrates a sector 52 whose physical block number=0, physical sector number=1, logical sector number=100, and sector state=“DATA VALID”; a sector 52 whose physical block number=0, physical sector number=2, logical sector number=10, and sector state=“DATA INVALID”; and so on.
FIG. 23 is a data structure diagram showing a structure of management data (hereinafter referred to as the “sector information table 12”) stored in the file system memory section 3 of the file system shown in FIG. 19, showing the number of physical sectors 52 for each sector state within each physical block 51. Specifically, the sector information table 12 shows the number of “UNUSED” sectors 52, the number of “DATA VALID” sectors 52, and the number of “DATA INVALID” sectors 52 in each erasure block 51.
In the sector information table 12 of FIG. 23, each information unit consists of a physical block number, the number of “UNUSED” sectors, the number of “DATA VALID” sectors, and the number of “DATA INVALID” sectors. Thus, the sector information table 12 illustrates an erasure block 51 whose physical block number=0, number of “UNUSED” sectors=100, number of “DATA VALID” sectors=20, and number of “DATA VALID” sectors=7; an erasure block 51 whose physical block number=1, number of “UNUSED” sectors=0, number of “DATA VALID” sectors=50, and number of “DATA INVALID” sectors=77; and so on.
The block information table 10 (FIG. 21), the sector information table 11 (FIG. 22), and the sector information table 12 (FIG. 23) are generated by reading the block control sector 52a of each erasure block 51 from the flash memory section 5 via the flash memory control section 4 by the file system control section 2 at the time when the file system 1 is activated.
It would be possible to use the file system 1 without generating the block information table 10, the sector information table 11, and the sector information table 12 because the information of these tables is stored in the block control sector 52a of each erasure block 51. However, when the file system memory section 3 is formed of a RAM, for example, the file system memory section 3 operates at a faster speed than the flash memory section 5. Therefore, by storing the generated block information table 10, sector information table 11, and sector information table 12 in the file system memory section 3, it becomes possible to quickly grasp the internal state of the flash memory section 5 and where given data is stored. In addition, the operation speed of the file system 1 can be effectively enhanced by utilizing the file system memory section 3 because the amount of data exchanged with the flash memory section 5 is reduced.
(Data Read Operation)
FIG. 24 is a flowchart illustrating a read operation for data which is stored in the flash memory section 5 according to a conventional technique.
First, referring to FIG. 24, when a data read request for reading data from the flash memory section 5 is issued from the application or operating system 6, the read request and a logical sector number are supplied from the application or operating system 6 to the file system control section 2.
The file system control section 2 accesses the sector information table 11 in the file system memory section 3 to search for the supplied logical sector number and confirm that the logical sector number has the “DATA VALID” sector state. The file system control section 2 obtains a physical sector number corresponding to this logical sector number, and supplies the obtained physical sector number to the flash memory control section 4 (Step 121).
The flash memory control section 4 accesses the flash memory section 5 based on this physical sector number to perform a read operation for a sector at a physical storage location that corresponds to the physical sector number. The flash memory control section 4 supplies the data which has been read to the file system control section 2 (Step 122).
If there is more data to be read, the control returns to Step 121 (following the “YES” path from Step 123). If there is no more data to be read, the control is terminated (following the “NO” path from Step 123).
(Data Write Operation)
FIGS. 25 to 27 are flowcharts illustrating a write operation for writing data to the flash memory section 5 according to a conventional technique.
First, referring to FIG. 25, when a data write request for writing data to the flash memory section 5 is issued from the application or operating system 6, the write request, a logical sector number, and the data to be written are supplied from the application or operating system 6 to the file system control section 2.
The file system control section 2 accesses the sector information table 12 in the file system memory section 3 to obtain a physical block number which has the largest number of “UNUSED” sectors (such a physical block number indicates an erasure block 51 to which writing may be safely performed) (Step 131). The file system control section 2 confirms whether or not a physical block number has been successfully obtained (Step 132). If a physical block number has not been successfully obtained (following the “NO” path from Step 132), the file system 1 is reconstructed in order to secure an erasure block 51 to which writing may be safely performed (Step 133).
If a physical block number having the largest number of “UNUSED” sectors has been successfully obtained (following the “YES” path from Step 132), the file system control section 2 accesses the sector information table 11 to obtain a physical sector number which has the “UNUSED” sector state, from among the physical sector numbers that correspond to the physical block number obtained at Step 131 or 133. The file system control section 2 further accesses the sector information table 12 to decrement the number of “UNUSED” sectors corresponding to the physical block number by one and increment the number of “DATA VALID” sectors corresponding to the physical block number by one (Step 134).
Thereafter, the file system control section 2 accesses the block information table 10 to confirm whether the block state associated with the physical block number obtained at Step 131 or 133 is “UNUSED” or not (Step 135). If the block state is confirmed to be “UNUSED” (following the “YES” path from Step 135), the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4. The file system control section 2 changes the logical block number of the block control sector 52a of the erasure block 51 corresponding to the physical block number obtained at Step 131 or 133 to that physical block number, and changes the block state of this block control sector 52a from “UNUSED” to “INCLUDES DATA”. Similarly, the file system control section 2 accesses the block information table 10, changes the logical block number corresponding to the physical block number obtained at Step 131 or 133 to that physical block number, and changes the block state of this block control sector 52a from “UNUSED” to “INCLUDES DATA” (Step 136). Then the control proceeds to Step 137. If the block state is not “UNUSED” (following the “NO” path from Step 135), the control skips Step 136 and proceeds to Step 137.
Next, referring to FIG. 26, the file system control section 2 accesses the sector information table 12 to confirm whether the number of “UNUSED” sectors corresponding to the physical block number obtained at Step 131 or 133 is 0 or not (Step 137). If the number of “UNUSED” sectors is 0 (following the “YES” path from Step 137), the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and changes the block state of the block control sector 52a of the erasure block 51 corresponding to that physical block number from “INCLUDES DATA” to “BLOCK FULL”. Similarly, the file system control section 2 accesses the block information table 10, and changes the block state associated with the physical block number obtained at Step 131 or 133 from “INCLUDES DATA” to “BLOCK FULL” (Step 138).
Next (or following the “NO” path from Step 137), the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and writes the logical sector number which has been supplied from the application or operating system 6 in the logical sector number within the block control sector 52a of the erasure block 51 that corresponds to the physical block number obtained at Step 131 or 133 and to the physical sector number obtained at Step 134. Also, the file system control section 2 changes the sector state of this sector 52 from “UNUSED” to “WRITING DATA”. Similarly, the file system control section 2 accesses the sector information table 11, and changes the logical sector number that corresponds to the physical block number obtained at Step 131 or 133 and to the physical sector number obtained at Step 134 to the logical sector number which has been supplied from the application or operating system 6. Also, the file system control section 2 changes the sector state of this sector 52 from “UNUSED” to “WRITING DATA” (Step 139).
Thereafter, the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and writes the data which has been supplied from the application or operating system 6 to the sector 52 that corresponds to the physical block number obtained at Step 131 or 133 and to the physical sector number obtained at Step 134 (Step 140).
After completing writing to the sector 52 within the flash memory section 5, the file system control section 2 changes the sector state within the block control sector 52a of the erasure block 51 that corresponds to the physical block number obtained at Step 131 or 133 and to the physical sector number obtained at Step 134 from “WRITING DATA” to “DATA WRITE COMPLETE”. Similarly, the file system control section 2 accesses the sector information table 11, and changes the sector state that corresponds to the physical block number obtained at Step 131 or 133 and to the physical sector number obtained at Step 134 from “WRITING DATA” to “DATA WRITE COMPLETE” (Step 141).
Then, the file system control section 2 confirms whether or not the data which has been written to the sector 52 within the flash memory section 5 is an update of any data that has already been written in the flash memory section 5 (Step 142).
If the written delta is updated data, (following the “YES” path from Step 142), the file system control section 2 accesses the sector information table 11, and obtains the physical sector number and the physical block number of a sector 52 in which any existing data is stored (i.e., a sector 52 which has the same logical sector number as the logical sector number of the sector 52 for which writing was performed at Step 140 but which has a different physical sector number from the physical sector number of the sector 52 for which writing was performed at Step 140) (Step 143 in FIG. 27).
Then, the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and changes the sector state within the block control sector 52a of the erasure block 51 that corresponds to the aforementioned physical block number and physical sector number from “DATA VALID” to “DATA INVALID”. Similarly, the file system control section 2 accesses the sector information table 11, and changes the sector state that corresponds to the aforementioned physical block number and physical sector number from “DATA VALID” to “DATA INVALID”. The file system control section 2 further accesses the sector information table 12 to decrement the number of “DATA VALID” sectors corresponding to this physical block number by one and increment the number of “DATA INVALID” sectors corresponding to this physical block number by one (Step 144).
Thereafter, the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and changes the sector state within the block control sector 52a of the erasure block 51 that corresponds to the physical block number and the physical sector number obtained at Step 143 from “DATA WRITE COMPLETE” to “DATA VALID”. Similarly, the file system control section 2 accesses the sector information table 11, and changes the sector state that is associated with the aforementioned physical block number and physical sector number from “DATA WRITE COMPLETE” to “DATA VALID” (Step 145).
Subsequently, the file system control section 2 confirms whether there is any more data to be written (Step 146). If there is more data to be written (following the “YES” path from Step 146), the control returns to Step 131. If there is no more data to be written (following the “NO” path from Step 146), the data write operation is terminated.
(Reconstruction Process)
FIGS. 28 and 29 are flowcharts illustrating a reconstruction process in the flow of FIG. 25 (Step 133).
If the “NO” path from Step 132 was taken, in FIG. 28, the file system control section 2 accesses the sector information table 12, and receives a physical block number which has the largest number of “DATA INVALID” sectors. The file system control section 2 also accesses the block information table 10 to obtain a logical block number that corresponds to the obtained physical block number (Step 151).
The file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and changes the logical block number of the block control sector 52a of the reserve erasure block 51 that has been secured in advance for use in the reconstruction of the file system 1 to the logic block number obtained at Step 151, and changes the block state of the block control sector 52a from “UNUSED” to “RECEIVING DATA”. Similarly, the file system control section 2 accesses the block information table 10, changes the logical block number of the reserve erasure block 51 to the logical block number obtained at Step 151, and changes the block state from “UNUSED” to “RECEIVING DATA” (Step 152).
Next, in order to efficiently copy data from the erasure block 51 having the physical block number obtained at Step 151 to the reserve erasure block 51, the file system control section 2 accesses the sector information table 11, and searches for and obtains a physical sector number which has the “DATA VALID” sector state, among the physical sector numbers corresponding to the physical block number obtained at Step 151 (Step 153).
If a sector 52 exists which has the “DATA VALID” sector state (following the “YES” path from Step 154), the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and copies a “DATA VALID” sector state within the block control sector 52a of the erasure block 51 that corresponds to the physical block number obtained at Step 151 and to the physical sector number obtained at Step 153, to a sector state within the block control sector 52a of the reserve erasure block 51 that corresponds to the same physical sector number. Similarly, the file system control section 2 accesses the sector information table 11, and copies the “DATA VALID” sector state that corresponds to the physical block number obtained at Step 151 and to the physical sector number obtained at Step 153, to the sector state of the same physical sector number within the reserve erasure block 51. At the same time, the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and copies data from the sector 52 within the erasure block 51 that corresponds to the physical block number obtained at Step 151 and to the physical sector number obtained at Step 153, to the sector 52 having the same physical sector number within the reserve erasure block 51 (Step 155).
Next (or following the “NO” path from Step 154), the file system control section 2 confirms whether or not an unprocessed sector 52 exists in the erasure block 51 having the physical block number obtained at Step 151 (Step 156). If an unprocessed sector 52 exists (following the “YES” path from Step 156), the control returns to Step 153. If no unprocessed sector 52 exists (following the “NO” path from Step 156), the data copying has been completed.
Accordingly, referring to FIG. 29, the file system control section 2 accesses the sector information table 12, and copies the number of “DATA VALID” sectors corresponding to the physical block number obtained at Step 151 to the number of “DATA VALID” sectors in the reserve erasure block 51. The file system control section 2 sets the number of “DATA INVALID” sectors to 0. The file system control section 2 calculates and sets the number of “UNUSED” sectors so that the sum of the number of “DATA VALID” sectors, the number of “DATA INVALID” sectors, and the number of “UNUSED” sectors equals the total number of sectors (i.e., 127) (Step 157).
Next, the file system control section 2 accesses the flash memory section 5 via the flash memory control section 4, and changes the block state of the block control sector 52a of the reserve erasure block 51 from “RECEIVING DATA” to “ERASING ORIGINAL BLOCK” (Step 158);
Then, the file system control section 2 erases the data in the erasure block 51 having the physical block number obtained at Step 151 (Step 159); and then changes the block state of the block control sector 52a of the reserve erasure block 51 from “ERASING ORIGINAL BLOCK” to “INCLUDES DATA”.
Similarly, the file system control section 2 accesses the block information table 10, and changes the block state of the block control sector 52a of the reserve erasure block 51 from “RECEIVING DATA” to “ERASING ORIGINAL BLOCK” (Step 158), and after the data erasure at Step 159, changes the block state of the reserve erasure block 51 from “ERASING ORIGINAL BLOCK” to “INCLUDES DATA”.
Thus, the block having the physical block number obtained at Step 151, i.e., the block whose data has been erased, is secured as a new reserve erasure block 51 (Step 160).
At this time, the block state of the block control sector 52a of the erasure block 51 whose data was erased at Step 159 automatically changes from “INCLUDES DATA” or “DATA FULL” to “UNUSED” through the data erasure. In the block information table 10, the sector information table 11, and the sector information table 12, the erasure block 51 whose data was erased at Step 159 appears as a reserve erasure block. Since the reserve erasure block 51 will not be referred to during a data write operation for the flash memory section 5, the items corresponding to the physical block number of the reserve erasure block 51 do not need to be changed.
In the above conventional data management system, when attempting to store a group of data into consecutive unused address regions in erasure blocks (typically, one erasure block has a size of 64 kilobytes or 8 kilobytes), the data sometimes cannot be successfully stored over a plurality of erasure blocks. For example, when attempting to store data of 5 kilobytes, if the amount an unused space in each erasure block is smaller than 5 kilobytes, the data cannot be stored even in the case where the total size of distributed unused spaces is 5 kilobytes or more. Moreover, when the size of an erasure block is 64 kilobytes, data greater than 64 kilobytes cannot be stored.
In a conventional data storage method where data having a greater size than that of an erasure block is divided and stored in a plurality of erasure blocks in a distributed manner, information about immediately-previous and immediately-subsequent data storage sites is added to each data as link information. The data having a greater size than that of an erasure block is stored over a plurality of erasure blocks while following the link information. In this case, if many groups of data having a relatively small size (smaller than the size of a block) are processed in units of a block, many small memory spaces where no data is contained are left unused in the blocks, and accordingly, the efficiency of storage in the memory region becomes significantly low. Thus, in view of the above-described disadvantages of flash memories, in order to use a flash memory in a disk drive, such as a hard disk drive, it is necessary to decrease the units in which data is processed to about several hundreds of bytes, which are the units in which data is processed in many hard disk drives.